package com.citahub.util;

import com.citahub.cita.protocol.core.methods.response.AppBlock;
import link.luyu.protocol.link.Connection;
import link.luyu.protocol.network.Block;

import java.io.Serializable;

public class InternalBlock implements Serializable {
    public long blockNumber;
    public String hash;
    public long timeStamp;

    public InternalBlock(AppBlock appBlock) {
        this.blockNumber = appBlock.getBlock().getHeader().getNumberDec().longValue();
        this.hash = appBlock.getBlock().getHash();
        this.timeStamp = appBlock.getBlock().getHeader().getTimestamp();
    }

    public Block toBlock() {
        Block block = new Block();
        block.setNumber(blockNumber);
        block.setHash(hash);
        block.setTimestamp(timeStamp);
        // todo 完善字段
        block.setBytes(new byte[] {}); // mock
        return block;
    }
}
